/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerMainLogin {
    
    /**
     * declaration of views and variables
     */
    Views.MainLogin mainLogin;
    ActionListener actionListener;
    
    /**
     * Default constructor to instantiate views 
    */
    public ControllerMainLogin(){
        mainLogin = new Views.MainLogin();
        mainLogin.setVisible(true);
    }
    
    /**
     * Method to get source of button clicked using action listener
     */
    
    public void control(){        
        actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) { 
                if(actionEvent.getSource()==mainLogin.getReceptionLoginBtn()){ 
                   ControllerReceptionLogin Login=new ControllerReceptionLogin();
                   Login.control();
                   mainLogin.setVisible(false);
                  }
                if(actionEvent.getSource()==mainLogin.getDoctorLoginBtn()){ 
                   ControllerDoctorLogin login= new ControllerDoctorLogin();
                   login.control();
                   mainLogin.setVisible(false); 
                  }
                if(actionEvent.getSource()==mainLogin.getAdminLoginBtn()){ 
                   ControllerAdminLogin login = new ControllerAdminLogin();
                   login.control();
                   mainLogin.setVisible(false);
                  }
           }
        };
        mainLogin.getReceptionLoginBtn().addActionListener(actionListener);
        mainLogin.getDoctorLoginBtn().addActionListener(actionListener);
        mainLogin.getAdminLoginBtn().addActionListener(actionListener);
    }
}
